package afternoon;

import java.util.Random;

public class Try_Catch02 {



    public static void main(String[] args) {
        
        try {
            getArr();
            getres();
            getres1();
        } catch (ArithmeticException e) {
            System.out.println("除零异常");
        }catch (ArrayIndexOutOfBoundsException e){
            System.out.println("数组越界");
        }catch (NullPointerException e){
            System.out.println("空指针异常");
        }

    }


      static void getres1() {
          Random random = new Random();
          int i1 = random.nextInt(10)+1;
        int[] array = new int[i1];
        System.out.println("数组的第三索引是"+array[3]);
    }

      static void getres() {
          Random random = new Random();
          int i1 = random.nextInt(4);
        int[] arr = new int[3];

        System.out.println("数组索引");
    }

      static void getArr() {
          Random random = new Random();
          int i1 = random.nextInt(4);
           int  i = 20/i1;
        System.out.println("除数为"+i);
    }


}
